package com.nju.edu.erp.service.hr;

import com.nju.edu.erp.dao.StuffDao;
import com.nju.edu.erp.model.po.StuffPO;

import java.math.BigDecimal;

public class MonthPayOnly implements GetSalaryWithTax {

    private final StuffDao stuffDao;

    MonthPayOnly(StuffDao stuffDao){
        this.stuffDao=stuffDao;
    }

    @Override
    public BigDecimal getSalaryWithTax(String name) {
        StuffPO stuffPO=stuffDao.getStuffByName(name);
        BigDecimal salaryWithTax=stuffPO.getBaseSalary().add(stuffPO.getJobSalary());
        //计算出勤率
        BigDecimal attendanceTime= BigDecimal.valueOf(stuffPO.getCheckIn());
        BigDecimal attendanceRate = attendanceTime.divide(BigDecimal.valueOf(30));
        System.err.println("salaryWithTax:"+salaryWithTax);
        System.err.println("attendanceTime:"+attendanceTime);

        salaryWithTax=salaryWithTax.multiply(attendanceRate);
        return salaryWithTax;
    }
}
